﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace Tycho.Persistence {
    public class SerializedObject {
    }

    
    public class SerializedList : SerializedObject {
        public List<SerializedObject> Items { get; set; }

        public SerializedList (IEnumerable<SerializedObject> items) {
            Items = new List<SerializedObject> (items);
        }

        public SerializedList () {
            Items = new List<SerializedObject> ();
        }
    }

    public class SerializedStructure : SerializedObject {
        public class Field {
            public SerializedSymbol Name;
            public SerializedObject Value;

            Field () { }

            public Field (SerializedSymbol name, SerializedObject value) {
                Name = name;
                Value = value;
            }
        }

        public List<Field> Fields { get; set; }

        public SerializedStructure () {
            Fields = new List<Field> ();
        }

        public SerializedStructure (SerializedSymbol name, SerializedObject value)
            : base () {
            Fields.Add (new Field (name, value));
        }
    }

    public abstract class SerializedData<T> : SerializedObject {
        public T Value { get; set; }

        protected SerializedData () { }

        protected SerializedData (T value) {
            Value = value;
        }
    }

    public class SerializedNull : SerializedObject {
    }

    public class SerializedReference : SerializedData<Guid> {
        SerializedReference () { }
        public SerializedReference (Guid g) : base (g) { }
    }

    public class SerializedBinaryData : SerializedData<byte []> {
        SerializedBinaryData () { }
        public SerializedBinaryData (byte [] data) : base (data) { }
    }

    public class SerializedInteger : SerializedData<int> {
        SerializedInteger () { }
        public SerializedInteger (int i) : base (i) { }
    }

    public class SerializedReal : SerializedData<double> {
        SerializedReal () { }
        public SerializedReal (double d) : base (d) { }
    }

    public class SerializedString : SerializedData<string> {
        SerializedString () { }
        public SerializedString (string s) : base (s) { }
    }

    public class SerializedBoolean : SerializedData<Boolean> {
        SerializedBoolean () { }
        public SerializedBoolean (bool b) : base (b) { }
    }

    public class SerializedDateTime : SerializedData<DateTime> {
        SerializedDateTime () { }
        public SerializedDateTime (DateTime dt) : base (dt) { }
    }

    public class SerializedSymbol : SerializedData<string> {
        SerializedSymbol () { }
        public SerializedSymbol (string symbol) : base (symbol) { }
    }
}
